package com.example.photo.model.domain;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.math.BigDecimal;

import com.example.photo.model.request.add.NewWorkRequest;
import com.example.photo.model.request.update.UpdateWorkRequest;
import lombok.Data;

/**
 * 作品
 * @TableName work
 */
@TableName(value ="work")
@Data
public class Work implements Serializable {
    /**
     * 作品id
     */
    @TableId(type = IdType.AUTO)
    private Integer workId;

    /**
     * 封面文件
     */
    private String coverFile;

    /**
     * 作品文件
     */
    private String workFile;

    /**
     * 作品名
     */
    private String workTitle;

    /**
     * 作者id
     */
    private Integer makerId;

    /**
     * 所属组
     */
    private Integer contestGroup;

    /**
     * 所属赛事id
     */
    private Integer contestId;

    /**
     * 作品描述
     */
    private String description;

    /**
     * 所获奖项
     */
    private Integer prizeId;

    /**
     * 是否过审
     */
    private Integer isPass;

    /**
     * 浏览量
     */
    private Integer views;

    /**
     * 平均分
     */
    private BigDecimal average;

    /**
     * 打分人数
     */
    private Integer scorerNum;

    /**
     * 是否删除
     */
    @TableLogic
    private Integer isDeleted;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    public Work() {
    }

    public Work(NewWorkRequest newWorkRequest, Integer makerId) {
        this.workFile = newWorkRequest.getWorkFile();
        this.workTitle = newWorkRequest.getWorkTitle();
        this.makerId = makerId;
        this.contestGroup = newWorkRequest.getContestGroup();
        this.contestId = newWorkRequest.getContestId();
        this.description = newWorkRequest.getDescription();
        this.isPass = 0;
        this.views = 0;
    }
    public Work(UpdateWorkRequest updateWorkRequest) {
        this.workId = updateWorkRequest.getWorkId();
        this.workFile = updateWorkRequest.getWorkFile();
        this.workTitle = updateWorkRequest.getWorkTitle();
        this.description = updateWorkRequest.getDescription();
    }
}